<template>
	<view>
		<view v-for="(item,index) in serveList" :key="index" @click="goDetail(item)">
			<view class="list-item">
				<view class="list-item-l">
					<image :src="item.picUrlsImage" mode="scaleToFill" style="width: 176rpx;height: 176rpx;"/>
					<view style="margin-left: 20rpx;width: 426rpx;">
						<text class="list-item-title">{{item.name}}</text>
						<view class="">
							<text class="list-item-c1">咨询领域： <text class="list-item-c2">{{item.domainDict==-1 ? '不限':item.domainDict}}</text> </text>
						</view>
						
						<view style="margin-top: 30rpx;display: flex;">
							<view class="">
								<text style="color: #F35C22;font-size: 28rpx;">¥</text>
								<text style="color: #F35C22;font-size: 40rpx;font-weight: 600;">{{item.price}}</text>
							</view>
							
							<view class="list-item-buy">
								去购买
							</view>
						</view>
						
					</view>
				</view>
			</view>
			
			
		</view>
	</view>
	
	
</template>

<script>
	let app = ''
	export default{
		data(){
			return{
				serveList:[],
				page:1,
				size:10,
				total:0,
			}
		},
		onLoad() {
			app = getApp()
			let _this = this
			_this.getGoodsList()
		},
		onShow() {
			
		},
		onPullDownRefresh() {
			let _this = this
			_this.page = 1
			_this.serveList = []
			_this.getGoodsList()
		},
		onReachBottom() {
			let _this = this
			
			if(_this.page == _this.total){
				uni.showToast({
					title:'暂无更多',
					icon:"none"
				})
				return
			}
			_this.page = _this.page+1
			_this.getGoodsList()
		},
		mounted() {
			// this.loadList()
			
		},
		methods:{
			/**
			 * 加载列表
			 */
			async getGoodsList(){
				console.log('getGoodsList')
				let _this = this
				let parmars = {
					page:_this.page,
					size:_this.size
				}
				const res = await _this.$myRequest({
					url: "/client/goods/list",
					data:parmars,
					method:'POST',//默认是GET
				})
				console.log('列表',res)
				if(res.data.code==200){
					let list = res.data.data.list
					if(_this.page===1){
						_this.total = res.data.data.total
					}
					for (var i = 0; i < list.length; i++) {
						list[i]['picUrlsImage']  = await _this.$imageUrls({
							picUrls:list[i].picUrls
						})
						list[i]['price'] = (list[i]['price']/100).toFixed(2)
						_this.serveList.push(list[i])
					}
				}
				
			},
			/**
			 * 跳转详情
			 */
			goDetail(item){
				let id = item.id
				uni.navigateTo({
					url:'../serveDetail/serveDetail?id='+id
				})
				
			},
		}
	}
</script>

<style>
	page{
		background-color: #f7f7f7;
	}

</style>

<style scoped lang="scss">
	.list-item{
		width: 686rpx;
		margin-left: 32rpx;
		padding-top: 24rpx;
		padding-bottom: 24rpx;
		background-color: white;
		margin-top: 24rpx;
		display: flex;
		/* align-items: center; */
	}
	.list-item-l{
		height: 176rpx;
		display: flex;
		align-items: center;
		margin-left: 32rpx;
		margin-right: 32rpx;
	}
	.list-item-title{
		font-size: 28rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #333333;
		line-height: 40rpx;
	}
	.list-item-c1{
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 34rpx;
		margin-top:16rpx;
	}
	.list-item-c2{
		color: #333333;
	}
	.list-item-buy{
		width: 143rpx;
		height: 56rpx;
		background-color: #E8F7FB;
		margin-left: auto;
		border-radius: 56rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #2DA9C5;
	}
</style>